<template>
  <div class="body1" style="padding-top:10px;">
    <div class="form_select">
      <div>
          <el-input class="select_input" size="small" v-model="form.title" placeholder="关键字"></el-input>
          <el-date-picker
            v-model="form.sdate"
            type="date"
            placeholder="选择开始日期" 
            size="small" 
            class="select_option1"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            >
          </el-date-picker>
          <el-date-picker
            v-model="form.edate"
            type="date"
            placeholder="选择结束日期" 
            size="small" 
            class="select_option1"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            >
          </el-date-picker>
          <el-button type="primary"  size="small" @click="getList">搜索</el-button>
      </div>
      <div class="select_right">
          <el-button type="primary" size="small" @click="dialog">导出excel</el-button>
          <el-button type="primary" size="small" @click="dialog('addCost')">+新增流水</el-button>
      </div>
    </div>
    <costTable :list="list" @func="dialogClose"></costTable>
    <addCost :show="addCostShow" @func="dialogClose"></addCost>
    <editCost :show="editCostShow" @func="dialogClose" :form="editCost"></editCost>
    </div>
   </div>


</template>
 
<script>
import addCost from "./addCost"
import editCost from "./editCost"
import costTable from "./costTable"
export default {
  name: "Cost",
  data() {
    return {
      list:[],
      form:{},
      addCostShow:false,
      editCostShow:false,
      editCost:[]
    };
  },
  components: {
    "addCost": addCost,
    "editCost": editCost,
    "costTable": costTable
  },
  created: function() {
    this.getList()
  },
  methods: {
    getList:function(){
      this.form.oa_id = localStorage.getItem('oa_id')
      var that = this
      this.$get('pc/cost/all',this.form).then((res) => {
        that.list = res.data
      })
    },
    dialog:function(key){
      this[key+'Show'] = !this[key+'Show']
    },
    dialogClose:function(data){
      this[data.key+'Show'] = !this[data.key+'Show']
      if(data.type){
        this.getList()
      }
      if(data.item){
        this[data.key] = data.item
      }
    }
  }
};
</script>
<style>
</style>